package utilities;

import java.io.PrintStream;
import java.util.ArrayList;

import types.ApproximData;

public class Printers
{
	public static void printSystem(
			double[][] m,
			PrintStream out
	) {
		final int h = m.length - 1;
		double[] freeVarsCol = m[h];
		for ( int row = 0; row < h; ++row )
		{
			double[] rowArr = m[row];
			for ( double val : rowArr )
				out.print( val + "\t" );
			out.println( freeVarsCol[row] );
		}
	}
	public static void printMap(
			int[][] m,
			PrintStream out
	) {
		final int h = m.length;
		for ( int row = 0; row < h; ++row )
		{
			int[] rowArr = m[row];
			for ( int val : rowArr )
				out.print( val + "\t" );
			out.println();
		}
	}
	public static void printApproxim(
			ApproximData approximData,
			PrintStream ps
	) {
		final ArrayList<double[][]> systems = approximData.systems();
		final int setsCount = systems.size();
		ps.println( "Sets count: " + setsCount );
		ps.println( "Map:" );
		printMap( approximData.imgMap(), ps );
		ps.println( "===============================" );
		ps.println( "Systems:" );
		int setNum = 0;
		for ( double[][] system : systems )
		{
			ps.println( "\tSystem number " + setNum++ );
			printSystem( system, ps );
			ps.println( "\t===============================" );
		}
		ps.println( "=======================" );
		ps.println( "=======================" );
	} // void printApproxim
}
